home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / CoreFoundation / CFNumber.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  5.0 KB  |  186 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        CFNumber.h
  3.  
  4.      Contains:    CoreFoundation numbers
  5.  
  6.      Version:    Technology:    Mac OS X
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __COREFOUNDATION_CFNUMBER__
  18. #define __COREFOUNDATION_CFNUMBER__
  19.  
  20. #ifndef __COREFOUNDATION_CFBASE__
  21.     #include <CoreFoundation\CFBase.h>
  22. #endif
  23.  
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. #if PRAGMA_ENUM_ALWAYSINT
  48.     #pragma enumsalwaysint on
  49. #elif PRAGMA_ENUM_OPTIONS
  50.     #pragma option enum=int
  51. #elif PRAGMA_ENUM_PACK
  52.     #if __option(pack_enums)
  53.         #define PRAGMA_ENUM_PACK__COREFOUNDATION_CFNUMBER__
  54.     #endif
  55.     #pragma options(!pack_enums)
  56. #endif
  57.  
  58. typedef const struct __CFBoolean * CFBooleanRef;
  59. extern const CFBooleanRef kCFBooleanTrue;
  60. extern const CFBooleanRef kCFBooleanFalse;
  61. EXTERN_API_C( CFTypeID )
  62. CFBooleanGetTypeID                (void);
  63.  
  64.  
  65. /* Returns the value of the given CFBoolean instance. */
  66. EXTERN_API_C( Boolean )
  67. CFBooleanGetValue                (CFBooleanRef             boolean);
  68.  
  69.  
  70.  
  71. enum CFNumberType {
  72.                                                                 /* Types from MacTypes.h */
  73.     kCFNumberSInt8Type            = 1,
  74.     kCFNumberSInt16Type            = 2,
  75.     kCFNumberSInt32Type            = 3,
  76.     kCFNumberSInt64Type            = 4,
  77.     kCFNumberFloat32Type        = 5,
  78.     kCFNumberFloat64Type        = 6,                            /* 64-bit IEEE 754 */
  79.                                                                 /* Basic C types */
  80.     kCFNumberCharType            = 7,
  81.     kCFNumberShortType            = 8,
  82.     kCFNumberIntType            = 9,
  83.     kCFNumberLongType            = 10,
  84.     kCFNumberLongLongType        = 11,
  85.     kCFNumberFloatType            = 12,
  86.     kCFNumberDoubleType            = 13,                            /* Other */
  87.     kCFNumberCFIndexType        = 14,
  88.     kCFNumberMaxType            = 14
  89. };
  90. typedef enum CFNumberType CFNumberType;
  91.  
  92. typedef const struct __CFNumber * CFNumberRef;
  93. extern const CFNumberRef kCFNumberPositiveInfinity;
  94. extern const CFNumberRef kCFNumberNegativeInfinity;
  95. extern const CFNumberRef kCFNumberNaN;
  96. EXTERN_API_C( CFTypeID )
  97. CFNumberGetTypeID                (void);
  98.  
  99.  
  100. /* Creates a CFNumber with the given value. The type of number pointed
  101. to by the valuePtr is specified by type. If type is a floating point
  102. type and the value represents one of the infinities or NaN, the
  103. well-defined CFNumber for that value is returned. If either of valuePtr
  104. or type is an invalid value, the result it undefined. */
  105. EXTERN_API_C( CFNumberRef )
  106. CFNumberCreate                    (CFAllocatorRef         allocator,
  107.                                  CFNumberType             theType,
  108.                                  const void *            valuePtr);
  109.  
  110.  
  111. /* Returns the storage format of the CFNumber's value.  Note that
  112. this is not necessarily the type provided in CFNumberCreate(). */
  113. EXTERN_API_C( CFNumberType )
  114. CFNumberGetType                    (CFNumberRef             number);
  115.  
  116.  
  117. /* Returns the size in bytes of the type of the number. */
  118. EXTERN_API_C( CFIndex )
  119. CFNumberGetByteSize                (CFNumberRef             number);
  120.  
  121.  
  122. /* Returns TRUE if the type of the CFNumber's value is one of the defined floating point types. */
  123. EXTERN_API_C( Boolean )
  124. CFNumberIsFloatType                (CFNumberRef             number);
  125.  
  126.  
  127. /* Copies the CFNumber's value into the space pointed to by
  128. valuePtr, as the specified type. If conversion needs to take
  129. place, the conversion rules follow human expectation and not
  130. C's promotion and truncation rules.  If the conversion is
  131. lossy, or the value is out of range, FALSE is returned. Best
  132. attempt at conversion will still be in *valuePtr.  */
  133. EXTERN_API_C( Boolean )
  134. CFNumberGetValue                (CFNumberRef             number,
  135.                                  CFNumberType             numType,
  136.                                  void *                    valuePtr);
  137.  
  138.  
  139. /* Compares the two CFNumber instances. If conversion of the
  140. types of the values is needed, the conversion and comparison
  141. follow human expectations and not C's promotion and comparison
  142. rules. Negative zero compares less than positive zero.
  143. Positive infinity compares greater than everything except
  144. itself, to which it compares equal. Negative infinity compares
  145. less than everything except itself, to which it compares equal.
  146. Unlike standard practice, if both numbers are NaN, then they
  147. compare equal; if only one of the numbers is NaN, then the NaN
  148. compares greater than the other number if it is negative, and
  149. smaller than the other number if it is positive. [Note that in
  150. CFEqual() with two CFNumbers, if either or both of the numbers
  151. is NaN, FALSE is returned.] */
  152. EXTERN_API_C( CFComparisonResult )
  153. CFNumberCompare                    (CFNumberRef             number,
  154.                                  CFNumberRef             otherNumber,
  155.                                  void *                    context);
  156.  
  157.  
  158. #if PRAGMA_ENUM_ALWAYSINT
  159.     #pragma enumsalwaysint reset
  160. #elif PRAGMA_ENUM_OPTIONS
  161.     #pragma option enum=reset
  162. #elif defined(PRAGMA_ENUM_PACK__COREFOUNDATION_CFNUMBER__)
  163.     #pragma options(pack_enums)
  164. #endif
  165.  
  166. #if PRAGMA_STRUCT_ALIGN
  167.     #pragma options align=reset
  168. #elif PRAGMA_STRUCT_PACKPUSH
  169.     #pragma pack(pop)
  170. #elif PRAGMA_STRUCT_PACK
  171.     #pragma pack()
  172. #endif
  173.  
  174. #ifdef PRAGMA_IMPORT_OFF
  175. #pragma import off
  176. #elif PRAGMA_IMPORT
  177. #pragma import reset
  178. #endif
  179.  
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183.  
  184. #endif /* __COREFOUNDATION_CFNUMBER__ */
  185.  
  186.